package com.xkdx.caipiao.presistence.bank;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xkdx.caipiao.module.network.AbsModule;

public class SupportBankListModule extends AbsModule {

	public LinkedHashMap<String, String> map; // 保证顺序存储
	public ArrayList<AddBankInfo> list;

	public SupportBankListModule() {

	}

	@Override
	public void parseData() throws Exception {
		try {
			backJson = (JSONArray) result;
			list = new ArrayList<AddBankInfo>();
			for (int i = 0; i < backJson.size(); i++) {
				jsonObj = (JSONObject) backJson.get(i);
				String sortOfAct = jsonObj.getString("Act");
				if (sortOfAct.equals("getSupportBankList")) {
					parseGetsupportBank(jsonObj.getJSONObject("DetailInfo"));
				}

			}
		} catch (Exception e) {
			throw e;
		}

	}

	private void parseGetsupportBank(JSONObject person) throws Exception {
		try {
			//
			// for (Map.Entry me : person.entrySet()) {
			// String key = (String) me.getKey();
			// String value = (String) me.getValue();
			// map.put(key, value);
			// }
			String[] json = person.toString().replace("{", "").replace("}", "").replace("\"", "").split(",");
			for (int i = 0; i < json.length; i++) {
				String[] bank = json[i].split(":");
				AddBankInfo info = new AddBankInfo();

				info.setBankId(bank[0]);
				info.setBankName(bank[1]);
				list.add(info);
			}

		} catch (Exception e) {

			throw e;
		}
	}
}
